import 'package:flutter/material.dart';

import 'tabs/home.dart';
import 'tabs/shopping.dart';
import 'tabs/My.dart';
class Tabs extends StatefulWidget{
  _Tabs createState()=>_Tabs();
}
class _Tabs extends State<Tabs>{
  int _currentIndex = 0;
  List list = [
    homePage(),
    shopPing(),
    My()
  ];
  @override
  Widget build(BuildContext context){
    return Scaffold(
        appBar: AppBar(
          title: Text("状态练习"),
        ),
        body: this.list[this._currentIndex],
        bottomNavigationBar: BottomNavigationBar(
          currentIndex: this._currentIndex,
          onTap: (int r){
            setState(() {

             this._currentIndex = r; 
            });
            print(r);
          },
          fixedColor: Colors.green,
          iconSize: 20,
          type: BottomNavigationBarType.fixed,
          items:[
            // 如果tab值超过4底部导航栏会被挤压，这时候需要使用属性type属性
            BottomNavigationBarItem(
              icon:Icon(Icons.home),
              title: Text("首页"),
            ),
            BottomNavigationBarItem(
              icon:Icon(Icons.card_giftcard),
              title: Text("购物"),
            ),
            BottomNavigationBarItem(
              icon:Icon(Icons.message),
              title: Text("我的"),
            ),
            BottomNavigationBarItem(
              icon:Icon(Icons.card_giftcard),
              title: Text("购物"),
            ),
            BottomNavigationBarItem(
              icon:Icon(Icons.message),
              title: Text("我的"),
            ),
          ]
          
        )
      );
  }
}